<?php

/**
 * contact : 刘经理 19326416371
 * company : 版权所属 四川北星惯牌科技有限公司
 **/

namespace app\common\model;

use think\Model;


class Team extends Model
{

    CONST IS_STORE_YES = 1;
    CONST IS_STORE_NO = 0;
    const PAY_STATUS_SUCCESS = 1;
    const PAY_STATUS_INTI = 0;


    const RELEASE_STATUS_SUCCESS = 1;
    const RELEASE_STATUS_NO = 0;
    const RELEASE_STATUS_CANCEL = 2;

    const DELETED_STATUS_SUCCESS = 1;
    const DELETED_STATUS_NO = 0;

    const SYSTEM_YES = 1;
    const SYSTEM_NO = 0;

    const CONFIRM_YES = 1;
    const CONFIRM_NO = 0;

    CONST TYPE_AVERAGE = 0;
    CONST TYPE_CONTRACT = 1;

    const STATUS_WRITE_OFF = 1;
    CONST STATUS_NO_WRITE_OFF = 0;
    // 表名
    protected $name = 'team';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'release_text',
        'delete_text'
    ];
    

    
    public function getReleaseList()
    {
        return ['0' => __('Release 0'), '1' => __('Release 1')];
    }

    public function getDeleteList()
    {
        return ['0' => __('Delete 0'), '1' => __('Delete 1')];
    }


    public function getReleaseTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['release']) ? $data['release'] : '');
        $list = $this->getReleaseList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getDeleteTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['delete']) ? $data['delete'] : '');
        $list = $this->getDeleteList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function user()
    {
        return $this->belongsTo('User', 'captain', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
